Repository navigation
fix: recover the daemon from a wedged audio worker - #64
Merged
Merged
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
My local daemon wedged and every
saycame backbusy, so stack-nudge went quiet. Sampling it showed the worker deadlocked in PortAudio's stream stop against CoreAudio's own IO thread (each holding a lock the other wants).cancelcan't reach it since_streamis already cleared by the time thefinallyinspeakruns, andstoptimed out with the process still alive. Onlykill -9got it back, so this has the daemon get itself out, andstopfinish the job when it can't.Hit it again a week later somewhere else, the worker sat in PortAudio's
WriteStreamfor nearly two days writing to a FiiO DAC that had stopped taking audio. stack-nudge kept cancelling and retrying,canceldoes abort the stream there but the write never came back, so every nudge was accepted and nothing played. The watchdog catches that one too since it doesn't care where the worker is stuck.Changes
sayreports not running instead of busy, and anything that starts the daemon on demand gets a fresh onesay --fileisn't killed when a nudge queues behind it. Dense text (numbers, acronyms) at speed 0.5 measured about 3.4 chars/s, hence the 2stopsends SIGKILL if the daemon acked but is still up after 5s, then clears the socket and pid file unless a newer daemon owns themtextwitherr: text must be a string. The worker arms its deadline fromlen(text)outside playback's try, so{"text": 5}would have killed it (cubic caught this)Testing
pytest(291),ruff check,ruff format --checkandmypy stackvoxall clean. The 17 new tests fail against main'sdaemon.pyspeakthat never returns: three accepted, fourthbusy, then it exited 70 after about 5s with the socket gonestopkilled it after 5s and exited 0stack-nudge still drops a nudge or two while the new daemon loads its model, that's a separate fix on the stack-nudge side.